﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils.Menu;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraTabbedMdi;
//using ERP_RORZE_TOOL.Tool.Forms;
//using ERP_RORZE.Tool.UserControls;
//using ERP_RORZE_TOOL;
//using ERP_RORZE_TOOL.Common;
using ERP_RORZE_DLL;
using ERP_RORZE_ORDER.OrderObject.UserControls;
using ERP_RORZE_PRODUCT.Product;
using ERP_RORZE_TOOL.Common;
using ERP_RORZE_TOOL.Tool.BCThoigianlamviecthang;
using ERP_RORZE_TOOL.Tool.BaoCaoKeHoach;
using ERP_RORZE_TOOL.Tool.CheckThoiGianLamViec;
using ERP_RORZE_TOOL.Tool.Forms;
using ERP_RORZE_TOOL.Tool.NGNoibo;
using ERP_RORZE_TOOL.Tool.UserControls;

namespace ERP_RORZE
{
	public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
	{
        
        private bool businessLoad;
        private bool assemblyLoad;
        private bool systemLoad;
        private ERP_RORZE_DLL.Business.BusinessPanel businessPanel;
        private ERP_RORZE_DLL.Assembly.AssemblyPanel assemblyPanel;
        private ERP_RORZE_DLL.BasicList.BasicListPanel basiclistPanel;

        //Tool cutting
	    private GridView gridView;

        public MainForm()
		{
			InitializeComponent();
            businessLoad = false;
            assemblyLoad = false;
            systemLoad = false;
            
            CallSystemPanel();
            InitToolControls();
		}

		private void ribbonControl1_SelectedPageChanged(object sender, EventArgs e)
		{
            switch (ribbonControl1.SelectedPage.Name)
            {
                case "businessTab":
                    //CallBusinessPanel();
                    break;

                case "assemblyTab":
                    //CallAssemblyPanel();
                    break;

                case "systemTab":
                    CallSystemPanel();
                    break;

                default:
                    this.panelMain.Controls.Clear();
                    break;
            }
            //tools cutting
            if (ribbonControl1.SelectedPage == rpProduct || ribbonControl1.SelectedPage == rpToolCutting)
            {
                rpCatProducTool.Visible = true;

            }
            else
            {
                rpCatProducTool.Visible = false;
            }

            if (ribbonControl1.SelectedPage == rpToolCutting)
            {
                //uc_Main fr = new uc_Main();
                //panelMain.Controls.Clear();
                //panelMain.Controls.Add(fr);
                //fr.Dock = DockStyle.Fill;

            }//end tools cutting       

            if (ribbonControl1.SelectedPage == rpProduct)
            {
                //ctrl_ProductMain fr = new ctrl_ProductMain();
                //panelMain.Controls.Clear();
                //panelMain.Controls.Add(fr);
                //fr.Dock = DockStyle.Fill;

            }
		}

		private void barButtonItem27_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
		{
			DatabaseConnection DatabaseConnectionForm = new DatabaseConnection();
			DatabaseConnectionForm.ShowDialog();

        }


        ///////////////////////////
        /// Call System Panel
        //////////////////////////
        private void CallSystemPanel()
        {
            if (!systemLoad)
            {
                this.basiclistPanel = new ERP_RORZE_DLL.BasicList.BasicListPanel();
                systemLoad = true;
            }
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(this.basiclistPanel);
            // 
            // systemPanel
            // 
            this.basiclistPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.basiclistPanel.Location = new System.Drawing.Point(2, 2);
            this.basiclistPanel.Name = "businessPanel";
            this.basiclistPanel.Size = new System.Drawing.Size(934, 286);
            this.basiclistPanel.TabIndex = 0;
        }

        ///////////////////////////
        /// Call Business Panel
        //////////////////////////
        private void CallBusinessPanel()
        {
            if (!businessLoad)
            {
                this.businessPanel = new ERP_RORZE_DLL.Business.BusinessPanel();
                businessLoad = true;
            }
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(this.businessPanel);
            // 
            // businessPanel
            // 
            this.businessPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.businessPanel.Location = new System.Drawing.Point(2, 2);
            this.businessPanel.Name = "businessPanel";
            this.businessPanel.Size = new System.Drawing.Size(934, 286);
            this.businessPanel.TabIndex = 0;
        }

        ///////////////////////////
        /// Call Assembly Panel
        //////////////////////////
        private void CallAssemblyPanel()
        {
            if (!assemblyLoad)
            {
                this.assemblyPanel = new ERP_RORZE_DLL.Assembly.AssemblyPanel();
                assemblyLoad = true;
            }
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(this.assemblyPanel);
            // 
            // assemblyPanel
            // 
            this.assemblyPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.assemblyPanel.Location = new System.Drawing.Point(2, 2);
            this.assemblyPanel.Name = "assemblyPanel";
            this.assemblyPanel.Size = new System.Drawing.Size(934, 286);
            this.assemblyPanel.TabIndex = 0;
        }

        private void barImportQuotation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            
        }

        #region tool cutting

        private void bbtImport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form fr = new frm_ImportAdd();
            fr.StartPosition = FormStartPosition.CenterParent;
            fr.ShowDialog();
            Cursor.Current = Cursors.Default;
        }

        private void bbtJustNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            Form fr = new frm_JustNewAdd();
            fr.StartPosition = FormStartPosition.CenterParent;
            fr.ShowDialog();
            Cursor.Current = Cursors.Default;
        }

        private void bbtBorrow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            Form fr = new frm_BorrowAdd();
            fr.StartPosition = FormStartPosition.CenterParent;
            fr.ShowDialog();
            Cursor.Current = Cursors.Default;
        }

        private void bbtBroken_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form fr = new frm_BrokenAdd();
            fr.StartPosition = FormStartPosition.CenterParent;
            fr.ShowDialog();
            Cursor.Current = Cursors.Default;
        }

        private void bbtReturn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form fr = new frm_ReturnAdd();
            fr.StartPosition = FormStartPosition.CenterParent;
            fr.ShowDialog();
            Cursor.Current = Cursors.Default;
        }

        ////////////////////
        ///report
        //////////////////
        private void subImportDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FImportDetails, subImportDetails.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FImportDetails, subImportDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;
            
            Cursor.Current = Cursors.Default;
        }

        private void subMonthlyImport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FMonthlyImport, subMonthlyImport.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FMonthlyImport, subMonthlyImport.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subUseDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FUseDetails, subUseDetails.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FUseDetails, subUseDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subNewOldDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FNewOldDetails, subNewOldDetails.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FNewOldDetails, subNewOldDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subBorrowDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FBorrowDetails, subBorrowDetails.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FBorrowDetails, subBorrowDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subTotalToolAtFactoryBorrowAtPresent_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrowAtPresent, subTotalToolAtFactoryBorrowAtPresent.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrowAtPresent, subTotalToolAtFactoryBorrowAtPresent.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subTotalMachineAtFactoryCrosstabBorrow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryCrosstabBorrow, subTotalMachineAtFactoryCrosstabBorrow.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subTotalMachineAtFactoryBorrow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrow, subTotalMachineAtFactoryBorrow.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FTotalMachineAtFactoryBorrow, subTotalMachineAtFactoryBorrow.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;
            Cursor.Current = Cursors.Default;
        }

        private void subTonKhoTongHop_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FTonKhoTongHop, subTonKhoTongHop.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;

            this.gridView = rp.GridView;
            Cursor.Current = Cursors.Default;
        }

        private void subQTotalInstock1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.QTotalInstock1, subQTotalInstock1.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QTotalInstock1, subQTotalInstock1.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;
            Cursor.Current = Cursors.Default;
        }

        private void subQTotalInStockAtPresent_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.QTotalInStockAtPresent, subQTotalInStockAtPresent.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QTotalInStockAtPresent, subQTotalInStockAtPresent.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;

            this.gridView = rp.GridView;
            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyInStockQuery_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyInStock_Query, subQMonthlyInStockQuery.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyInStockQueryQuantity_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyInStock, subQMonthlyInStockQueryQuantity.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subFReturnDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            //uc_rpt_Tool rp = new uc_rpt_Tool(ToolConstants.Configuration.ReportName.FReturnDetails, subFReturnDetails.Caption);
            //this.panelMain.Controls.Clear();
            //this.panelMain.Controls.Add(rp);
            //rp.Dock = DockStyle.Fill;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FReturnDetails, subFReturnDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subFLossDetails_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FLossDetails, subFLossDetails.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subFDailyBroken_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.FDailyBroken, subFDailyBroken.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBroken2CrosstabAmountUSD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBroken2CrosstabAmountUSD, subQMonthlyBroken2CrosstabAmountUSD.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBroken2CrosstabQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBroken2CrosstabQty, subQMonthlyBroken2CrosstabQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMachineCrosstabAmountUSD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMachineCrosstabAmountUSD, subQMonthlyBrokenMachineCrosstabAmountUSD.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMachineCrosstabQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMachineCrosstabQty, subQMonthlyBrokenMachineCrosstabQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenCustomer2CrosstabQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenCustomer2CrosstabQty, subQMonthlyBrokenCustomer2CrosstabQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenCustomer2CrosstabAmountUSD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenCustomer2CrosstabAmountUSD, subQMonthlyBrokenCustomer2CrosstabAmountUSD.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBroken3CrosstabToolGroupAmount_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBroken3CrosstabToolGroupAmount, subQMonthlyBroken3CrosstabToolGroupAmount.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBroken3CrosstabToolGroupQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBroken3CrosstabToolGroupQty, subQMonthlyBroken3CrosstabToolGroupQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMaterial2CrosstabAmountUSD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMaterial2CrosstabAmountUSD, subQMonthlyBrokenMaterial2CrosstabAmountUSD.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMaterial2CrosstabQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMaterial2CrosstabQty, subQMonthlyBrokenMaterial2CrosstabQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMistake2CrosstabAmountUSD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMistake2CrosstabAmountUSD, subQMonthlyBrokenMistake2CrosstabAmountUSD.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQMonthlyBrokenMistake2CrosstabQty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QMonthlyBrokenMistake2CrosstabQty, subQMonthlyBrokenMistake2CrosstabQty.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void subQTotalMachineBrokenCrosstab_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            uc_rpt_GridView rp = new uc_rpt_GridView(ToolConstants.Configuration.ReportName.QTotalMachineBrokenCrosstab, subQTotalMachineBrokenCrosstab.Caption);
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(rp);
            rp.Dock = DockStyle.Fill;
            this.gridView = rp.GridView;

            Cursor.Current = Cursors.Default;
        }

        private void bbtExportSelected_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Utilities.ExportToExcel(gridView, 0, true);
        }

        private void bbtExportAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Utilities.ExportToExcel(gridView, 1, true);

        }

        private void InitToolControls()
        {
            PopupMenu popupMenuImport = new PopupMenu();
            PopupMenu popupMenuJustNew = new PopupMenu();
            PopupMenu popupMenuBorrow = new PopupMenu();
            PopupMenu popupMenuBroken= new PopupMenu();
            PopupMenu popupMenuReturn = new PopupMenu();

            bbItemImport.ItemClick += bbItemImport_ItemClick;
            bbItemJustnew.ItemClick += bbItemJustnew_ItemClick;
            bbItemBorrow.ItemClick += bbItemBorrow_ItemClick;
            bbItemBroken.ItemClick += bbItemBroken_ItemClick;
            bbItemReturn.ItemClick += bbItemReturn_ItemClick;

            popupMenuImport.ItemLinks.Add(bbItemImport);
            popupMenuJustNew.ItemLinks.Add(bbItemJustnew);
            popupMenuBorrow.ItemLinks.Add(bbItemBorrow);
            popupMenuBroken.ItemLinks.Add(bbItemBroken);
            popupMenuReturn.ItemLinks.Add(bbItemReturn);

            bbtImport.DropDownControl = popupMenuImport;
            bbtBorrow.DropDownControl = popupMenuBorrow;
            bbtJustNew.DropDownControl = popupMenuJustNew;
            bbtBroken.DropDownControl = popupMenuBroken;
            bbtReturn.DropDownControl = popupMenuReturn;

        }

        void bbItemReturn_ItemClick(object sender, ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            ucReturn ucReturn = new ucReturn();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucReturn);
            ucReturn.Dock = System.Windows.Forms.DockStyle.Fill;
            ucReturn.Location = new System.Drawing.Point(2, 2);
            ucReturn.Name = "ucReturn";
            ucReturn.TabIndex = 0;
            this.gridView = ucReturn.GridView;
            Cursor.Current = Cursors.Default;

        }

        void bbItemBroken_ItemClick(object sender, ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            ucBroken ucBroken = new ucBroken();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucBroken);
            ucBroken.Dock = System.Windows.Forms.DockStyle.Fill;
            ucBroken.Location = new System.Drawing.Point(2, 2);
            ucBroken.Name = "ucBroken";
            ucBroken.TabIndex = 0;
            this.gridView = ucBroken.GridView;
            Cursor.Current = Cursors.Default;

        }

        void bbItemBorrow_ItemClick(object sender, ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            ucBorrow ucBorrow = new ucBorrow();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucBorrow);
            ucBorrow.Dock = System.Windows.Forms.DockStyle.Fill;
            ucBorrow.Location = new System.Drawing.Point(2, 2);
            ucBorrow.Name = "ucBorrow";
            ucBorrow.TabIndex = 0;
            this.gridView = ucBorrow.GridView;

            Cursor.Current = Cursors.Default;
        }

        void bbItemJustnew_ItemClick(object sender, ItemClickEventArgs e)
        {

            Cursor.Current = Cursors.WaitCursor;
            ucJustNew ucJustNew = new ucJustNew();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucJustNew);
            ucJustNew.Dock = System.Windows.Forms.DockStyle.Fill;
            ucJustNew.Location = new System.Drawing.Point(2, 2);
            ucJustNew.Name = "ucJustNew";
            ucJustNew.TabIndex = 0;
            this.gridView = ucJustNew.GridView;
            Cursor.Current = Cursors.Default;
        }

	    void bbItemImport_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ucImport ucImport = new ucImport();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucImport);
            // 
            // ucImport
            // 
            ucImport.Dock = System.Windows.Forms.DockStyle.Fill;
            ucImport.Location = new System.Drawing.Point(2, 2);
            ucImport.Name = "ucImport";
            ucImport.TabIndex = 0;
            this.gridView = ucImport.GridView;
            Cursor.Current = Cursors.Default;
        }

        ///
        /// Product Query
        /// 

        private void subBCThoiGianLamViecthang_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ucBCTimeMonth ucBcTimeMonth = new ucBCTimeMonth();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucBcTimeMonth);
            // 
            // ucBcTimeMonth
            // 
            ucBcTimeMonth.Dock = System.Windows.Forms.DockStyle.Fill;
            ucBcTimeMonth.Location = new System.Drawing.Point(2, 2);
            ucBcTimeMonth.Name = "ucBcTimeMonth";
            ucBcTimeMonth.TabIndex = 0;
            Cursor.Current = Cursors.Default;
        }

        private void subNGNoibo_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ucNGNoibo ucNgNoiBo = new ucNGNoibo();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucNgNoiBo);
            // 
            // ucNgNoiBo
            // 
            ucNgNoiBo.Dock = System.Windows.Forms.DockStyle.Fill;
            ucNgNoiBo.Location = new System.Drawing.Point(2, 2);
            ucNgNoiBo.Name = "ucNgNoiBo";
            ucNgNoiBo.TabIndex = 0;
            Cursor.Current = Cursors.Default;
        }


        private void subCheckThoiGianLamViec_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ucCheckWorkTime ucCheck = new ucCheckWorkTime();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucCheck);
            // 
            // ucNgNoiBo
            // 
            ucCheck.Dock = System.Windows.Forms.DockStyle.Fill;
            ucCheck.Location = new System.Drawing.Point(2, 2);
            ucCheck.Name = "ucCheck";
            ucCheck.TabIndex = 0;
            Cursor.Current = Cursors.Default;
        }


        private void bbtBcKeHoach_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ucBaoCaoKeHoach ucBcKh = new ucBaoCaoKeHoach();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(ucBcKh);
            // 
            // ucNgNoiBo
            // 
            ucBcKh.Dock = System.Windows.Forms.DockStyle.Fill;
            ucBcKh.Location = new System.Drawing.Point(2, 2);
            ucBcKh.Name = "ucBcKh";
            ucBcKh.TabIndex = 0;
            Cursor.Current = Cursors.Default;
        }
        #endregion

        private void bbtOrderProduct_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            ucProduct uc = new ucProduct();
            this.panelMain.Controls.Clear();
            this.panelMain.Controls.Add(uc);
            uc.Dock = DockStyle.Fill;
            
            Cursor.Current = Cursors.Default;
        }






    }
}
